# 更新 修改

"""
1.创建会话
"""
from sqlalchemy.orm import sessionmaker
from create_table_foreignkey import engine
Session = sessionmaker(engine)
db_session = Session()

from create_table_foreignkey import School, Student

'''
正向查询修改  修改Jack学生所在的校区
'''
sch = db_session.query(School).filter(School.name == "清华").first()
db_session.query(Student).filter(Student.name == "Jack").update({"school_id":sch.id})
db_session.commit()
db_session.close()